<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>结构伪类选择器</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
        }

        main {
            padding: 2rem;
            width: 1200px;
            background-color: #EEEEEE;
        }

        main div {
            margin-left: 1rem;
        }

        code {
            padding: 0.25rem 0.5rem;
            margin: 0 4px;
            background-color: rgba(27, 31, 35, .05);
            border-radius: 3px;
        }

        .message {
            font-size: 18px;
            font-weight: bold;
        }

        table {
            width: 600px;
            border: 1px solid #000;
            border-collapse: collapse;
        }

        th,
        td {
            padding: 8px;
            border: 1px solid #000;
        }

        table tr>td:nth-child(2n+1) {
            background: #339933;
            color: white;
        }
    </style>
</head>

<body>
    <main>
        <h1>计算数量</h1>
        <p>n 为 0/1/2/3... ，下面是隔列变色</p>
        <div>
            <table>
                <thead>
                    <tr>
                        <th>姓名</th>
                        <th>年龄</th>
                        <th>性别</th>
                        <th>地址</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>张三</td>
                        <td>21</td>
                        <td>男</td>
                        <td>上海市</td>
                    </tr>
                    <tr>
                        <td>李秋水</td>
                        <td>26</td>
                        <td>女</td>
                        <td>南京市</td>
                    </tr>
                    <tr>
                        <td>王五</td>
                        <td>22</td>
                        <td>男</td>
                        <td>北京市</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </main>
</body>

</html>